@extends('admin.master')

@section('page_header')
    <h1 class="page-title">
        <i class="voyager-file-text"></i>操作记录
    </h1>
    @stop

    @section('page_header_actions')

    @stop

    @section('content')
    <div class="page-content container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-bordered">
                    <div class="panel-body">
                        <table id="dataTable" class="table table-hover">
                            <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>操作人</th>
                                    <th>操作记录</th>
                                    <th>操作时间</th>
                                </tr>
                            </thead>
                            <tbody>
                            @foreach($logs as $data)
                                <tr>
                                    <td>{{$data->id}}</td>
                                    <td>{{$data->operator}}</td>
                                    <td>{{$data->log}}</td>
                                    <td>{{$data->created_at}}</td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @stop
    @section('javascript')
    <!-- DataTables -->
    <script>
        $(document).ready(function () {
            $('#dataTable').DataTable({ "order": [] });
        });
        $('td').on('click', '.delete', function (e) {
            var form = $('#delete_form')[0];
            form.action = parseActionUrl(form.action, $(this).data('id'));
            $('#delete_modal').modal('show');
        });
        function parseActionUrl(action, id) {
            return action.match(/\/[0-9]+$/)
                    ? action.replace(/([0-9]+$)/, id)
                    : action + '/' + id;
        }
    </script>
@stop
